//
//  YBEngine.h
//  YBNetworking
//
//  Created by ybgo on 2018/11/22.
//  Copyright © 2018 嘉联支付有限公司. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
@class YBRequest;

/**
 请求操作回调

 @param task NSURLSessionDataTask
 @param responseObject responseObject
 @param error error
 */
typedef void (^YBCompletionHandler) (NSURLSessionDataTask * _Nullable task, id _Nullable responseObject, NSError * _Nullable error);

@interface YBEngine : NSObject

/**
 创建 YBEngine 对象

 @return YBEngine 对象
 */
+ (instancetype)engine;

/**
 创建 YBEngine 单例对象

 @return 单利独享
 */
+ (instancetype)sharedEngine;

/**
 发送带回调的 YBRequest 网络请求

 @param request YBRequest 对象
 @param completionHandler 回调
 */
- (void)sendRequest:(YBRequest *)request completionHandler:(nullable YBCompletionHandler)completionHandler;

/**
 根据 identifier 取消当前正在请求中的请求

 @param identifier YBRequest 唯一标识
 @return YBRequest 对象
 */
- (nullable YBRequest *)cancelRequestByIdentifier:(NSString *)identifier;

/**
 根据 identifier 获取当前正在请求中的请求

 @param identifier YBRequest 唯一标识
 @return YBRequest 对象
 */
- (nullable YBRequest *)getRequestByIdentifier:(NSString *)identifier;

- (void)setConcurrentOperationCount:(NSInteger)count;

/**
 获取当前网络链接状态

 @return Network reachablity status code
 */
- (NSInteger)reachabilityStatus;

- (void)addSSLPinningURL:(NSString *)url;

- (void)addSSLPinningCert:(NSData *)cert;

- (void)addTwowayAuthenticationPKCS12:(NSData *)p12 keyPassword:(NSString *)password;

@end

NS_ASSUME_NONNULL_END
